package com.example.renyang.happysell;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.session.PlaybackState;
import android.support.annotation.MainThread;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Locale;

public class fragment_myInfo extends Fragment implements View.OnClickListener{

    private ImageView user_pic1;
    private TextView usernameTV1;

    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
        View view= inflater.inflate(R.layout.fragment_my_info, container, false);

        user_pic1=(ImageView)view.findViewById(R.id.user_pic);
        usernameTV1=(TextView)view.findViewById(R.id.usernameTV);

        view.findViewById(R.id.store_informationIV).setOnClickListener(this);
        view.findViewById(R.id.back_storeIV).setOnClickListener(this);
        view.findViewById(R.id.settingIV).setOnClickListener(this);
        view.findViewById(R.id.tuijianIV).setOnClickListener(this);
        view.findViewById(R.id.Edit_userIV).setOnClickListener(this);
        dialog();
        return view;
    }



    protected  void dialog(){
       AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
        builder.setTitle("请登录或注册");
        builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(getActivity(), "确认去登录", Toast.LENGTH_SHORT).show();
                Intent intent=new Intent();
                intent.setClass(getActivity(),LoginActivity.class);
                startActivity(intent);
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(getActivity(),"取消",Toast.LENGTH_SHORT).show();
            }
        });
        builder.setCancelable(true);//设置按钮是否可以按返回键取消,false则不可以取消
        AlertDialog dialog=builder.create();//创建对话框
        dialog.setCanceledOnTouchOutside(true);//设置弹出框失去焦点是否隐藏,即点击屏蔽其它地方是否隐藏
        dialog.show();
    }
    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.store_informationIV:
//                Intent store_informationIntent = new Intent(getActivity(),StoreManageActivity.class);
//                startActivity(store_informationIntent);
                break;
            case R.id.back_storeIV:
                break;
            case R.id.Edit_userIV:
                Intent Edit_userIntent = new Intent(getActivity(), EditUserActivity.class);
                startActivity(Edit_userIntent);
                break;
            case R.id.settingIV:
//                Intent settingIntent = new Intent(getActivity(),SettingActivity.class);
//                startActivity(settingIntent);
                break;
            case R.id.tuijianIV:
                break;
        }
    }
}
